<template>
  <t-dialog
    :header="header"
    :visible.sync="visible"
    :onClose="closeDialog"
    :closeOnOverlayClick="false"
    @confirm="onSubmit"
    mode="full-screen"
    width="90%"
    top="5%"
  >
    <div style="height: 80vh;">
<!--      <collect-detail  :reviewOpen="true" :objId="row.collectResult.id"></collect-detail>-->
      <file-review :header="dialog.header" :is-dialog="false" achievementType="zjb" :objId="row.collectResult.id"></file-review>

      <t-drawer
        :visible="drawerVisible"
        showInAttachedElement
        :showOverlay="false"
        size="30%"
        :preventScrollThrough="false"
        header="评审内容"
      >
        <edit-expert-review @reload="reload" ref="edit-expert-review"  :editOpen="editOpen" :expertEditOpen="expertEditOpen" :reviewType="row.reviewType" :objId="row.id" :teamId="row.teamId" :expertUserId="row.experts.userId" :visible.sync="dialog.open_review"></edit-expert-review>
        <template v-if="editOpen" #footer>
          <t-button theme="default" @click="closeDrawer">关闭评审界面</t-button>
          <t-button theme="primary" @click="onSubmit(1)">暂存</t-button>
          <t-button theme="primary" v-if="!closeSubmit" @click="onSubmit(2)">提交</t-button>
        </template>
        <template v-else #footer>
          <t-button theme="default" @click="closeDrawer">取消</t-button>
        </template>
      </t-drawer>
      <!--          <t-col :span="3" style="height: 65vh;overflow-y: scroll">-->
      <!--            <edit-expert-review @reload="reload" ref="edit-expert-review"  :editOpen="editOpen" :expertEditOpen="expertEditOpen" :reviewType="row.reviewType" :objId="row.id" :teamId="row.teamId" :expertUserId="row.experts.userId" :visible.sync="dialog.open_review"></edit-expert-review>-->
      <!--          </t-col>-->
    </div>
    <template  #footer>
      <t-button theme="default" @click="closeDialog">取消</t-button>
      <t-button theme="primary" @click="drawerVisible = true">打开评审界面</t-button>
    </template>

  </t-dialog>
</template>

<script>

import EditExpertReview from '../../../cgzh/review/components/edit-expert-review.vue'
import collectDetail from "../../../cgzh/collect/components/collect-detail.vue";
import fileReview from "../../../cgzh/components/file-review.vue";

export default {
  name: "cgzh-approve-info",
  components:{
    EditExpertReview,
    collectDetail,
    fileReview
  },
  props:["header", "row","expertEditOpen","editOpen","drawerVisibleOpen"],
  data(){
    return {
      visible: true,
      drawerVisible: this.drawerVisibleOpen,
      closeSubmit: false,
      dialog: {
        open_project_detail: false,
        open_outline_detail: false,
        open_contract_detail: false,
        open_review: false
      },
      formData: {
        id: this.objId,
        projectApproval: '1',
        score: null,
        content: '',
        projectItemScores: [],
        sysAttMainVo: {
          sysAttMainIds: []
        }
      },
    }
  },
  mounted() {
    // 在开会前，只能暂存，开会后，就能提交
    if(this.row?.reviewTeam?.reviewMeetingDate){
      const reviewMeetingDate = new Date(this.row.reviewTeam.reviewMeetingDate).getTime()
      const currentDate = new Date().getTime();
      if (currentDate < reviewMeetingDate) {
        this.closeSubmit = true;
      }
    }
  },
  methods:{
    onSubmit(type){
      this.$refs["edit-expert-review"].onSubmit(type)
    },
    closeDialog() {
      this.$emit("update:visible", false);
    },
    closeDrawer(){
      this.drawerVisible = false
    },
    reload(type){
      if(type===1){ // 暂存
        this.$emit("reload");
        // this.$emit("update:visible", false);
      }else{
        this.$emit("reload");
        this.$emit("update:visible", false);
      }
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ a{
  margin-right: 10px;
}
::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
  background-color: var(--td-scrollbar-color);
}
/deep/ .t-drawer .t-drawer__content-wrapper{
  height: calc(100% - var(--td-comp-size-xxxl));
  margin-top: var(--td-comp-size-xxxl);
}
/deep/ .t-drawer__header{
  display: none;
}
</style>
